#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  string str;
  while (cin >> str) {
    int n = str.size();
    const int inf = INT_MAX / 2;
    vector<vector<int>> dp(n, vector<int>(n, inf));
    for (int l = n - 1; l >= 0; l --) {
      dp[l][l] = 1;
      for (int r = l + 1; r < n; r ++) {
        // 分两段
        for (int k = l; k < r; k ++) {
          dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r]);
        }
        // 自成一段
        for (int len = 1; len <= (r - l + 1) / 2; len ++) {
          if ((r - l + 1) % len) continue;
          if ([&]() {
            for (int i = l + len; i + len - 1 <= r; i += len) {
              for (int j = 0; j < len; j ++) {
                if (str[l + j] != str[i + j]) return true;
              }
            }
            return false;
          }()) continue;
          int rep = (r - l + 1) / len;
          int cnt = 2 + dp[l][l + len - 1];
          if (rep >= 100) cnt += 3;
          else if (rep >= 10) cnt += 2;
          else cnt += 1;
          dp[l][r] = min(dp[l][r], cnt);
        }
      }
    }
    cout << dp[0][n - 1] << endl;
  }
}